// 路由 控制器
import { Get, Controller } from "@nestjs/common";
import { AppService } from "./app.service";
import { LoggerService } from "./logger.service";
import { FetchData } from "./fecthData.service";

@Controller("/")
export class AppController {
  // 容器自动识别app.module中providers中的依赖, import的AppService只是引入了类型 而不是实例化
  constructor(
    private appService: AppService,
    private logService: LoggerService,
    private fetchService: FetchData
  ) {}

  @Get("/test")
  fetchData() {
    let res = this.fetchService.getData("净利润(扣除非经常性损益后)(万元)");
    return res;
  }

  @Get("/cheerioTest")
  cheerioTest() {
    let res = this.fetchService.cheerioTest();
    return res;
  }

  @Get("/hello")
  hello() {
    // 控制器的方法直接调用service中的方法
    console.log(this.appService.getHello());
    let message = this.appService.getHello();
    return message;
  }
  @Get("/log")
  log() {
    let message = this.logService.log("打印");
    return message;
  }
}
